var app={};
Ext.ux.TinyMCE.initTinyMCE({language:"zh"});
//var typeid = window.opener.document.getElementById('treenodeid').value;
var typeid = "103";
var bannerid = "244";
//var bannerid = window.opener.document.getElementById('bannerid').value;

//增加大TAB页方法(传入参数标签名称及panel的ID)
function addTabbanner(banname,banid,dxc,hzc){	
	var knowaccessories_dx = new Ext.form.TextField({
		fieldLabel: '附件列表',
		readOnly: true,
		id: 'file_table_tc_'+banid,
		anchor: '100%'
	})
	var knowhtml_dx = new Ext.ux.TinyMCE({
			id:' k_tiny_tc_'+banid,
			name:' k_tiny_tc',
			anchor:"100%",
			height: 320,
			value: dxc,
			tinymceSettings: {
				theme : "advanced",skin : "o2k7",language:"zh",
				plugins: "safari,pagebreak,style,layer,table,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
				theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
				theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
				theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|",
				theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
				theme_advanced_toolbar_location : "top",
				theme_advanced_toolbar_align : "left",
				theme_advanced_statusbar_location : "bottom",
				readonly: true,
				theme_advanced_resizing : false,
				extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
				template_external_list_url : "example_template_list.js"
			}
	})
	var knowaccessories_hz = new Ext.form.TextField({
		fieldLabel: '附件列表',
		readOnly: true,
		id: 'file_table_partners_'+banid,
		anchor: '100%'
	})
	var knowhtml_hz = new Ext.ux.TinyMCE({
			id:  ' k_tiny_partners_'+banid,
			name: ' k_tiny_partners',
			anchor:"100%",
			height: 320,
			value: hzc,
			tinymceSettings: {
				theme : "advanced",skin : "o2k7",language:"zh",
				plugins: "safari,pagebreak,style,layer,table,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
				theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
				theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
				theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|",
				theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
				theme_advanced_toolbar_location : "top",
				theme_advanced_toolbar_align : "left",
				theme_advanced_statusbar_location : "bottom",
				theme_advanced_resizing : false,
				readonly: true,
				extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
				template_external_list_url : "lists/template_list.js"
			}
	})
	
	var addnewinfo_dx = new Ext.form.FormPanel({
		title: '电信知识',
		id: 'fp_tc'+banid,
		region: 'center',
		layout : 'column',
		labelAlign : 'right',
		labelWidth : 60,
		frame : true,
		defaults : {
					columnWidth : 1,
					layout : 'form',
					frame : false,
					border : false
				},
		items : [{
					items : [knowaccessories_dx]
				},{
					labelSeparator: ' ',
					labelWidth : 1,
					items : [knowhtml_dx]
				}]
	})

	var addnewinfo_hz = new Ext.form.FormPanel({
		title: '合作伙伴知识',
		id: 'fp_partners'+banid,
		layout : 'column',
		region: 'center',
		labelAlign : 'right',
		labelWidth : 60,
		frame : true,
		defaults : {
					columnWidth : 1,
					layout : 'form',
					frame : false,
					border : false
				},
		items : [{
						items : [knowaccessories_hz]
					},{
						labelSeparator: ' ',
						labelWidth : 1,
						items : [knowhtml_hz]
					}]
	})
	
	var itemtp = new Ext.TabPanel({
		region : 'center',
		id: 'item'+banid,
		deferredRender: false,
		activeTab : 0,
		enableTabScroll: true,
		plain : true,
		defaults : {
			autoScroll : true,
			frame : true
		}
	})

	itemtp.on('beforerender',function(){
		var tab_tab1 = itemtp.add(addnewinfo_dx);
		var tab_tab2 = itemtp.add(addnewinfo_hz);
		itemtp.doLayout();
		itemtp.setActiveTab(tab_tab1);
	})
	
	var knowTab = new Ext.Panel({
		title: banname,
		id: banid,
		layout: 'border',
		region: 'center',
		autoScroll: false,
		border: false,
		items: [itemtp]
	})
	
	return knowTab;
}
	
var knowtitle = new Ext.form.TextField({
	name: 'k_title',
	fieldLabel: '知识标题',
	id: 'k_title',
	anchor: '98%',
	readOnly: true
})
var knowauthor = new Ext.form.TextField({
	name: 'know_author',
	fieldLabel: '作者',
	anchor: '94%',
	readOnly: true
})
var knowabstract = new Ext.form.TextField({
	name: 'k_abstract',
	fieldLabel: '摘要',
	anchor: '98%',
	readOnly: true
})
var knowlevel = new Ext.form.TextField({
	name: 'k_level',
	fieldLabel: '文件等级',
	anchor: '98%',
	readOnly: true
})
var knowkeyword = new Ext.form.TextField({
	name: 'k_keyword',
	fieldLabel: '关键字',
	id: 'k_keyword',
	anchor: '98%',
	readOnly: true
})
var testdata = [
	['11','测试TAB','电信内容','合作对象内容']	
]
var teststore = new Ext.data.SimpleStore({
 fields:[{
  name:'bannerId',type:'string'
 },{
  name:'bannerName',type:'string'
 },{
  name:'dxContent',type:'string'
 },{
  name:'hzContent',type:'int'
 }],
 data:testdata
});


teststore.on('load',function(){
	var newtab = know_center.add(addTabbanner('测试TAB','11','电信内容','合作对象内容'));
	know_center.doLayout();
	know_center.setActiveTab(newtab);
})
	
var addnewFP = new Ext.form.FormPanel({
	layout: 'border',
	region: 'north',
	height: 100,
	border : false,
	labelAlign : 'right',
	labelWidth : 60,
	frame : true,
	items : [{
		layout : 'column',
		region : 'center',
		defaults : {
			columnWidth : 1,
			layout : 'form',
			frame : false,
			border : false
		},
		items : [{
					columnWidth : .7,
					items : [knowtitle]
				}, {
					columnWidth : .3,
					items : [knowauthor]
				},{
					columnWidth : .7,
					items : [knowabstract]
				}, {
					columnWidth : .3,
					items : [knowlevel]
				},{
					items : [knowkeyword]
				}]
			}]
})

var know_center = new Ext.TabPanel({
	region : 'center',
	deferredRender: false,
	plain : true,
	activeTab: 0,
	defaults : {
		autoScroll : true,
		frame : true
	},
	buttons : [{
			text: '同意'
	},{
			text: '不同意'
	}]
})
know_center.on('beforerender',function(){
	teststore.loadData(testdata);
})


// onReady装载组装页面
Ext.onReady(function() {
	Ext.BLANK_IMAGE_URL = "resources/images/default/s.gif";
	Ext.QuickTips.init();// 支持tips提示
	Ext.form.Field.prototype.msgTarget = 'side';// 提示的方式，枚举值为"qtip","title","under","side",id(元素id)
	new Ext.Viewport({
		id: 'addPanel',
		layout: 'border',
		renderTo: 'knowledgeshow',
		border : false,
		items: [addnewFP,know_center]
	})
})